<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const obj = {
      name: 'why',
      age: 18,
      height: 1.88,
      cities: ['北京', '上海', '广州'],
      xueke: {
        math: 100,
        english: 99
      }
    }

    // 获取对象所有的 key
    const keys = Object.keys(obj)
    console.log(keys)   // ["name", "age", "height", "cities", "xueke"]
    // 获取对象所有的 value
    const values = Object.values(obj)
    console.log(values)   // ["why", 18, 1.88, ["北京", "上海", "广州"], {math: 100, english: 99}]

    // 获取对象所有的 key 和 value
    const entries = Object.entries(obj)
    console.log(entries)   // [["name", "why"], ["age", 18], ["height", 1.88], ["cities", ["北京", "上海", "广州"]], ["xueke", {math: 100, english: 99}]]
    // 获取对象所有的 key 和 value
    for (let key in obj) {
      console.log(key, obj[key])
    }

    // Object.getOwnPropertyDescriptors(obj)  可以获取对象属性的具体信息，是否可以克隆、是否可以修改、是否可以删除
    const descriptors = Object.getOwnPropertyDescriptors(obj)
    console.log(descriptors)    // {name: {…}, age: {…}, height: {…}, cities: {…}, xueke: {…}}

  </script>
</body>

</html>